<template>
  <div class="profile-main-layout">
    <div class="profile-left">
      <div class="profile-avatar-box">
        <img :src="avatar" alt="头像" class="profile-avatar" />
        <div class="profile-username">{{ username }}</div>
        <div class="profile-motto">{{ motto }}</div>
        <button class="primary-btn mt-4" @click="goEdit">编辑资料</button>
      </div>
    </div>
    <div class="profile-right">
      <div class="profile-section profile-dynamic">
        <h3>生活动态</h3>
        <ul>
          <li v-for="item in posts" :key="item.id">{{ item.content }}</li>
          <li v-if="posts.length === 0" class="empty">暂无动态</li>
        </ul>
      </div>
      <div class="profile-section profile-goods">
        <h3>发布的二手告示</h3>
        <ul>
          <li v-for="item in goods" :key="item.id">{{ item.title }} - {{ item.desc }}</li>
          <li v-if="goods.length === 0" class="empty">暂无二手发布</li>
        </ul>
      </div>
      <div class="profile-section profile-schedule">
        <h3>个人课表</h3>
        <table class="schedule-table">
          <tr>
            <th>时间</th>
            <th>课程</th>
          </tr>
          <tr v-for="(item, idx) in schedule" :key="idx">
            <td>{{ item.time }}</td>
            <td>{{ item.course }}</td>
          </tr>
          <tr v-if="schedule.length === 0"><td colspan="2" class="empty">暂无课表</td></tr>
        </table>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const avatar = ref('https://cdn.jsdelivr.net/gh/duogongneng/oss-picbed/img/profile-default.png')
const username = ref('小明')
const motto = ref('努力让自己变得更好！')
const posts = ref([
  { id: 1, content: '今天阳光真好！' },
  { id: 2, content: '分享了一篇好文章。' },
])
const goods = ref([
  { id: 1, title: '九成新考研书', desc: '适合23考研，包邮' },
  { id: 2, title: '小米蓝牙耳机', desc: '音质好，几乎全新' },
])
const schedule = ref([
  { time: '周一 8:00-10:00', course: '高等数学' },
  { time: '周三 14:00-16:00', course: '大学英语' },
  { time: '周五 10:00-12:00', course: '计算机基础' },
])
function goEdit() {
  router.push('/main/profile/edit')
}
</script>

<style>
@import '@/assets/styles/common.css';
</style>

<style scoped>
.profile-main-layout {
  display: flex;
  gap: 36px;
  max-width: 1200px;
  margin: 40px auto;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 4px 32px rgba(37, 99, 235, 0.10);
  padding: 40px 32px;
}
.profile-left {
  width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1.5px solid #e5e7eb;
  padding-right: 32px;
}
.profile-avatar-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.profile-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  background: #e0e7ff;
  box-shadow: 0 2px 12px #2563eb22;
}
.profile-username {
  font-size: 1.25em;
  font-weight: bold;
  color: #2563eb;
  margin-top: 8px;
}
.profile-motto {
  color: #666;
  font-size: 1em;
  text-align: center;
  margin-top: 4px;
  word-break: break-all;
}
.mt-4 {
  margin-top: 16px;
}
.profile-right {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 32px;
  justify-content: space-between;
}
.profile-section {
  background: #f7faff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.06);
  padding: 24px 18px 18px 18px;
  min-width: 220px;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.profile-section h3 {
  color: #2563eb;
  font-size: 1.1em;
  margin-bottom: 8px;
}
ul {
  padding-left: 18px;
  margin: 0;
}
.empty {
  color: #aaa;
  margin: 8px 0;
}
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.schedule-table th, .schedule-table td {
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  text-align: left;
}
.schedule-table th {
  background: #f1f5ff;
}
@media (max-width: 1100px) {
  .profile-main-layout {
    flex-direction: column;
    padding: 24px 8px;
  }
  .profile-right {
    flex-direction: column;
    gap: 18px;
  }
  .profile-left {
    border-right: none;
    border-bottom: 1.5px solid #e5e7eb;
    padding-right: 0;
    padding-bottom: 18px;
    margin-bottom: 18px;
  }
}
</style>